-
Notifications
You must be signed in to change notification settings - Fork 10
Aws fastpath deploy #240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Aws fastpath deploy #240
Conversation
This server was running out of memory trying to bring up the fastpath docker container. I changed the instance type from one with 0.5gb of ram to one with 1gb of ram
If you don't the first time you run this notebook it will crash with "permission required" whenever you try to run a docker command
Terraform Run Output 🤖Format and Style 🖌
|
Pusher | @LDiazN |
Action | pull_request |
Environment | dev |
Workflow | .github/workflows/check_terraform.yml |
Last updated | Tue, 22 Jul 2025 07:33:04 GMT |
Ansible Run Output 🤖Ansible Playbook Recap 🔍
Ansible playbook output 📖
|
Pusher | @LDiazN |
Action | pull_request |
Working Directory | |
Workflow | .github/workflows/check_ansible.yml |
Last updated | Tue, 22 Jul 2025 07:33:26 GMT |
dest: "/opt/{{fastpath_user}}/backend" | ||
# TODO Change to `master` when https://github.com/ooni/backend/pull/935 is merged | ||
version: support-deploying-fastpath-as-docker-container | ||
force: yes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be ideal if we did this using the same pattern as the reset of the services. That would be building the docker image upon each commit in backend automatically and then we do the deploy using the tag.
It otherwise makes it harder to test something in dev and then deploy it inside of prod.
What we would ideally like to do is make a build, tag a version, test it in dev and then when the test passes we can deploy it to prod.
Can you make changes to run this as part of the CD pipeline?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure!
We are also missing another piece to get fastpath fully working and that is handling measurement upload. It's necessary to extract the api-uploader systemd unit and component over to fastpath (see: https://github.com/ooni/backend/blob/master/api/debian/ooni-api-uploader.timer). Other relevant docs are for these pieces are here: https://docs.ooni.org/backend/systemd-timers/#ooni-api-uploader-timer I guess we have 2 options on how to handle this:
|
I will probably go with 2, but I will address it in a follow up PR with that and setting up the access to s3 and clickhouse |
@@ -0,0 +1,9 @@ | |||
$ANSIBLE_VAULT;1.1;AES256 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What are we storing in the vault? Can we put this into aws_ssm
instead?
|
||
# Fastpath settings | ||
# TODO Update this to the actual clickhouse host when we have migrated it | ||
clickhouse_url: "clickhouse://default:default@clickhouse-server:9000" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have migrated it, should we then update it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, actually the fastpath is taking configurations from its the ansible/host_vars/fastpath.dev.ooni.io/vars.yml
file but I will update the default one to be the same
- name: Ensure fastpath is running | ||
community.docker.docker_container: | ||
name: fastpath | ||
image: ooni/fastpath:latest |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we place a specific version tag in here and make it as variable so we ensure we have the correct tested version?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I will this one that has the changes with the fastpath writing to disk:
https://hub.docker.com/layers/ooni/fastpath/v0.87/images/sha256-60b2d4e55fa4ba0a9aeb1e821e901e49f78141619eefa6ce45fd4ef251145ee0
- name: Install Statsd | ||
tags: uploader | ||
apt: | ||
name: python3-statsd |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably cleaner to use the pkg list here instead, like so:
- name: Install dependencies for uploader
tags: uploader
apt:
pkg:
- python3-statsd
- python3-boto3
... etc
[DEFAULT] | ||
# arn:aws:iam::676739448697:user/ooni-pipeline, AWS: OONI Open Data | ||
aws_access_key_id = AKIAJURD7T4DTN5JMJ5Q | ||
aws_secret_access_key = {{ s3_ooni_open_data_access_key }} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might have been placed in the vault. I suggest we move it instead into parameter store
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do that, I was using that pattern because it was used in other places for the same key:
s3_ooni_open_data_access_key: "{{ vault_s3_ooni_open_data_access_key }}" |
Should we update those places as well?
f"raw/{tstamp[:8]}/{tstamp[8:10]}/{cc}/{testname}/{jsonlf.name}" | ||
) | ||
if conf.get("run_mode", "") == "DESTROY_DATA": | ||
log.info("Testbed mode: Destroying postcans!") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This mode of operation scares me a bit. I would suggest we maybe remove it to avoid mistakes.
tf/environments/dev/main.tf
Outdated
from_port = 80, | ||
to_port = 80, | ||
protocol = "tcp", | ||
cidr_blocks = ["0.0.0.0/0"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it actually need permission to be accessed on port 80 from anywhere on the internet?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not actually, I will remove it
} | ||
|
||
module "fastpath_builder" { | ||
source = "../../modules/ooni_docker_build" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really need a new module for this? I see that the only thing that changes between ooni_docker_build
and ooniapi_service_deployer/
is that we are skipping the final Deploy
stage. Could we just pass that as an optional flag to it and avoid duplicating all the module code?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If it's too tricky though we can skip it
This PR will add an ansible role to deploy the fastpath as an EC2 isntance using Docker.
The ansible role will:
Known issues
For now this setup has an issue with the Docker installation where the docker role will try to reboot the SSH connection to apply docker group settings, but this seems to crash the next command:
There's also another issue where the Docker deployment fails because it can't create a network for the docker compose. This is fixed by manually rebooting the docker daemon:
systemctl restart docker
(see https://stackoverflow.com/questions/54380847/failed-to-setup-ip-tables-unable-to-enable-nat-rule)To solve this issue we have to ensure that docker is rebooted before starting the docker compose
This should be solved by
devops/ansible/roles/fastpath/tasks/main.yml
Line 45 in 4b148c6
Update
After the last review I added the following features:
closes #239